package com.edu.zql;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Created by User on 2017/7/11.
 */
public class APP {
    public static void main(String[] args) throws ParseException, IOException {

        Pattern pattern1 = Pattern.compile("[\\?&]id=\\d+");

        Matcher matcher1 = pattern1.matcher("https://item.taobao.com/item.htm?id=560890412261&_u=&pvid=&scm=");

        matcher1.find();

        String group = matcher1.group();

        System.out.println(group);


        String alias = "大码3XL";

        String processedAlias = alias.replace("[\\(（].*?[\\)）]", "");

        System.out.println(processedAlias);


        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(1510653420062L));

        System.out.println(format);

        try {
            throw new RuntimeException("123");
        } catch (Exception e) {
            System.out.println(e.toString());
        }


        System.out.println(sdasd());


        System.out.println("!!!!!!!!!!!!!!!");












        String ss = "姓名：小明 年龄：18 地址：中国：广东省 电话：123456";
        String arr [] = ss.split(" ");
        String ret = arr[2].substring(arr[2].indexOf("：")+1);
        System.out.println(ret);


        String brand = "zhuqianli/js";
        brand = brand.replace("/", "|");
        String reqTitle = "asdjsladjasdsZhuqInliladsald";
        System.out.println(Pattern.matches(".*((?i)"+brand+").*", reqTitle));

        String s = "M（170/88A）";


        System.out.println(s.replaceAll("[\\(（].*?[\\)）]", ""));
        System.out.println(1123);
        if (true) return;

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        long l = System.currentTimeMillis();
        System.out.println(simpleDateFormat.format(new Date(l)));
        l /= (24 * 3600 * 1000);
        System.out.println(l);
        l *= (24 * 3600 * 1000);
        System.out.println(simpleDateFormat.format(new Date(l)));

        // 获取当天0时时间戳   时间戳为0时：表示东八区的1970-1-1 08:00:00  时间戳为16*3600*1000时：表示东八区的1970-1-2 00:00:00 时间戳为-8*3600*1000时：表示东八区的1970-1-1 00:00:00
        long currentTimestamp = System.currentTimeMillis();

        System.out.println(simpleDateFormat.format(new Date(currentTimestamp)));

        long currentZeroTimeStamp = (currentTimestamp + 8 * 3600 * 1000) / (24 * 3600 * 1000) * (24 * 3600 * 1000) - (8 * 3600 * 1000);

        System.out.println(simpleDateFormat.format(currentZeroTimeStamp));





        Pattern compile1 = Pattern.compile("");

        System.out.println(1);


        Pattern pattern = Pattern.compile("([1-9]\\d?|[12]\\d{1,2}|3[0-5]\\d?|36[0-6])");
        for (int i= 1; i<=366 ;i++) {
            Matcher matcher = pattern.matcher(String.valueOf(i));
            if (matcher.matches() == false) {

                System.out.println(matcher.matches());
            }
        }
        Pattern compile = Pattern.compile("a[^a]+c");
        Matcher xaxaxcxaxcx = compile.matcher("xaxaxccxaxcx");
        xaxaxcxaxcx.find();
        System.out.println(xaxaxcxaxcx.group());


        InputStream resourceAsStream = APP.class.getClassLoader().getResourceAsStream("a/aa.xml");

        System.out.println(resourceAsStream);


    }



    private static void adsadasad() {
        System.out.println(-1 / 10);

        List list = new ArrayList();

        for (int i = 0; i < 10; i++) {
            list.add(i);
        }

        List list1 = list.subList(0, 3);

        System.out.println(list1);
    }

    private static void asdasdasdas() throws ParseException, IOException {
        int type =3 ;
        Boolean buyerRate, sellerRate;
        buyerRate = (type & 1) > 0 ? true : false;
        sellerRate = (type & 1<<1) > 0 ? true :false;
        System.out.println("买家:" + buyerRate +" 卖家:"+ sellerRate);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println(new Date(1500911999000L));
        System.out.println(simpleDateFormat.format(new Date(1500911999000L)));
        SimpleDateFormat ss = new SimpleDateFormat("yyyy-MM-dd");
        System.out.println("======" + ss.parse("2017-7-11").getTime());

        List list = new ArrayList();

        Object[] os = list.toArray();
        System.out.println();
        try {
            try{
                System.out.println("try1");
                int i = 1 / 0;
                System.out.println("try2");
            } catch (Exception e) {
                System.out.println("catch1");
                int i = 1 /0;
                System.out.println("catch2");
            }finally {
                System.out.println("finally");
            }
        } catch (Exception e){

        }


        String fileName = System.getProperty("user.dir").replaceAll("\\\\", "/") + "/2017-8-2190919.txt";
        System.out.println(fileName);
        FileOutputStream fileOutputStream = new FileOutputStream(fileName);
        fileOutputStream.close();
    }


    private static int sdasd() {
        int a = 0;
        try {

            if (true) throw new RuntimeException();
            return 3;

        } catch (Exception e) {
           a = 30;

           return a;
        } finally {
            System.out.println("finally");
            return a;
        }


    }

    private static void asdasd() {
        String a = "A|";
        String b = "B]";
        System.out.println(a.hashCode());
        System.out.println(b.hashCode());
        String c = "B|";
        String d = "C]";
        System.out.println(c.hashCode());
        System.out.println(d.hashCode());
    }

    private static void aaaa() {
        Map map = new HashMap();
        APP app = new APP();
        System.out.println(app.hashCode());


        User user1 = new User();
        user1.name = "1111123123123";
        User user2 = new User();
        System.out.println(user1.hashCode());//
        user1.name = "as";
        System.out.println(user1.hashCode());
        user1 = user2;
        System.out.println(user1.hashCode());
        System.out.println(user2.hashCode());
        map.put(user1, 1);
        //780376
        //29092282
    }

    private static boolean f() {
        long i = 1;
        if(i<60){
            return true;
        }else{
            return false;
        }
    }
}
